let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n143,
  i =
    (this && this.__extends) ||
    ((_n143 = function n(t, e) {
      return (_n143 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
    function (t, e) {
      function o() {
        this.constructor = t;
      }
      _n143(t, e),
        (t.prototype =
          null === e
            ? Object.create(e)
            : ((o.prototype = e.prototype), new o()));
    });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.ScienceItemCom = void 0);
var r = t('UIComponent'),
  a = t('ComUtils'),
  s = t('SoundMrg'),
  c = t('AbsInfo'),
  l = t('ResMrg'),
  u = t('BagMrg'),
  h = t('GeneralTips'),
  p = t('CivilizationMrg'),
  f = t('PlayerMrg'),
  d = t('WeakGuidePanel'),
  g = t('UIMrg'),
  _ = t('LangCfg'),
  y = (function (t) {
    function e(e, o) {
      var n = t.call(this, e) || this;
      return (
        (n._info = o),
        n._info.on(c.InfoEvent.LevelChanged, n.onLevelChangedHandler, n),
        n._info.on(
          c.InfoEvent.RedDotStateChanged,
          n.onRedDotStageChangedHandler,
          n
        ),
        n.onRedDotStageChangedHandler(),
        n.refresh(),
        n
      );
    }
    return (
      i(e, t),
      (e.prototype.onInit = function () {
        t.prototype.onInit.call(this),
          (this._imgIcon = a.default.getComponent(
            cc.Sprite,
            this.view,
            'imgIcon'
          )),
          (this._txtName = a.default.getComponent(
            cc.Label,
            this.view,
            'txtName'
          )),
          (this._txtLevel = a.default.getComponent(
            cc.Label,
            this.view,
            'txtLevel'
          )),
          (this._txtOpenLevel = a.default.getComponent(
            cc.Label,
            this.view,
            'txtOpenLevel'
          )),
          (this._txtAttr = a.default.getComponent(
            cc.Label,
            this.view,
            'txtAttr'
          )),
          (this._expense = a.default.getNode(this.view, 'expense')),
          (this._imgManji = a.default.getNode(this.view, 'imgManji')),
          (this._txtGold = a.default.getComponent(
            cc.Label,
            this._expense,
            'txtValue'
          )),
          (this._btnUpgrade = a.default.getComponent(
            cc.Button,
            this.view,
            'btnUpgrade'
          )),
          this._btnUpgrade.node.on(
            cc.Node.EventType.TOUCH_END,
            this.onTouchUpgradeHandler,
            this
          ),
          (this._redDot = a.default.getNode(
            this._btnUpgrade.node,
            'Background/redDot'
          ));
      }),
      (e.prototype.onLang = function () {
        t.prototype.onLang.call(this);
        var e = a.default.getComponent(
          cc.Label,
          this.view,
          'btnUpgrade/Background/txtLabel'
        );
        (e.string = _.LangCfg.ins.getContent(1018)),
          ((e = a.default.getComponent(
            cc.Label,
            this.view,
            'imgManji/txtLabel'
          )).string = _.LangCfg.ins.getContent(1019)),
          this._info &&
            ((this._txtName.string = _.LangCfg.ins.getContent(this._info.name)),
            (this._txtAttr.string = this.getAttributeDesc(this._info)));
      }),
      (e.prototype.refresh = function () {
        if (
          (l.ResMrg.loadSpriteByAtlas(
            this._imgIcon,
            'Atlas/Civilization',
            this._info.icon
          ),
          (this._txtName.string = _.LangCfg.ins.getContent(this._info.name)),
          this._info.level > 0)
        )
          (this._txtLevel.string = 'Lv.' + this._info.level),
            (this._txtAttr.string = this.getAttributeDesc(this._info)),
            (this._txtGold.string = this._info.money + ''),
            this._info.isMaxLevel
              ? ((this._btnUpgrade.node.active = !1),
                (this._expense.active = !1),
                (this._imgManji.active = !0))
              : ((this._btnUpgrade.node.active = !0),
                (this._expense.active = !0),
                (this._imgManji.active = !1)),
            (this._txtLevel.node.active = !0),
            (this._txtAttr.node.active = !0),
            (this._txtOpenLevel.node.active = !1),
            this.setGray(!1, !0);
        else {
          var t = p.CivilizationMrg.ins.getOpenScienceByType(this._info.type);
          t && (this._txtOpenLevel.string = t.name + '开放'),
            (this._txtOpenLevel.node.active = !0),
            (this._btnUpgrade.node.active = !1),
            (this._expense.active = !1),
            (this._imgManji.active = !1),
            (this._txtLevel.node.active = !1),
            (this._txtAttr.node.active = !1),
            this.setGray(!0, !0);
        }
        this._btnUpgrade.interactable = this._info.level < this._info.maxLevel;
      }),
      (e.prototype.onRedDotStageChangedHandler = function () {
        this._redDot.active = this._info.redDotState;
      }),
      (e.prototype.onLevelChangedHandler = function () {
        this.refresh();
      }),
      (e.prototype.onTouchUpgradeHandler = function () {
        if (
          (s.SoundMrg.click(),
          this._info.level < this._info.maxLevel
            ? u.BagMrg.ins.getCount(u.BagMrg.GOLD) >= this._info.money
              ? this._info.upgrade()
              : h.GeneralTips.notEnoughGold()
            : h.GeneralTips.show(
                _.LangCfg.ins.getContent(1012, {
                  n: _.LangCfg.ins.getContent(this._info.name)
                })
              ),
          f.PlayerMrg.ins.hasGuide(3))
        ) {
          var t = g.UIMrg.getPanel(d.WeakGuidePanel);
          t &&
            t.isShow &&
            (g.UIMrg.close(t), this.delayCall(0.1, this.showGuide));
        }
      }),
      (e.prototype.showGuide = function () {
        f.PlayerMrg.ins.showGuide(4);
      }),
      (e.prototype.getAttributeDesc = function (t, e) {
        void 0 === e && (e = '');
        var o = '';
        return (
          t.hp > 0 &&
            (o +=
              _.LangCfg.ins.getContent(1020, {
                n: t.hp
              }) + '\n'),
          t.atk > 0 &&
            (o +=
              _.LangCfg.ins.getContent(1021, {
                n: t.atk
              }) + '\n'),
          t.def > 0 &&
            (o +=
              _.LangCfg.ins.getContent(1022, {
                n: t.def
              }) + '\n'),
          t.crit > 0 &&
            (o +=
              _.LangCfg.ins.getContent(1023, {
                n: t.crit
              }) + '\n'),
          t.solid > 0 &&
            (o +=
              _.LangCfg.ins.getContent(1024, {
                n: t.solid
              }) + '\n'),
          t.hpPer > 0 &&
            (o +=
              _.LangCfg.ins.getContent(1025, {
                n: t.hpPer
              }) + '\n'),
          t.atkPer > 0 &&
            (o +=
              _.LangCfg.ins.getContent(1026, {
                n: t.atkPer
              }) + '\n'),
          t.defPer > 0 &&
            (o +=
              _.LangCfg.ins.getContent(1027, {
                n: t.defPer
              }) + '\n'),
          o.substring(0, o.length - 1)
        );
      }),
      e
    );
  })(r.UIComponent);
(o.ScienceItemCom = y), console.log('end');
module.exports = e.exports;
